package com.dynamo.transport.network.practise.nio.buffer;

import java.nio.ByteBuffer;

/**
 * @author duanyimiao
 * @create 2018-11-03 10:58 PM
 * @description
 **/
public class NioBuffer {

    public static void main(String[] args) {
        //对Nio中buffer使用


        ByteBuffer byteBuffer = ByteBuffer.allocate(10);

        byteBuffer.put((byte) 1);
        byteBuffer.put((byte) 3);
        byteBuffer.put((byte) 5);
        //切换到读模式
        byteBuffer.flip();
        System.out.println(byteBuffer.get());
        System.out.println(byteBuffer.get());

        byteBuffer.put(5,((byte) '2'));

        System.out.println(byteBuffer.get(2));

    }
}
